package com.fizzkai.p2p.core.query;

import com.fizzkai.p2p.core.util.DateUtil;
import com.fizzkai.p2p.core.util.StringUtil;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

@Getter
@Setter
public class IpLogQuery extends QueryObject {
    private String username; // 当前登录用户 的 username
    private Date beginTime;
    private Date endTime;
    private Integer state = -1;

    public Date getBeginTime() {
        return beginTime;
    }

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    public void setBeginTime(Date beginTime) {
        this.beginTime = beginTime;
    }

    public Date getEndTime() {
        return DateUtil.getEndDate(endTime);
    }

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public String getUsername() {
        return StringUtil.empty2null(username);
    }
}
